package com.djzhou.gmms.login.action;

import java.util.List;

import com.djzhou.gmms.base.action.BaseAction;
import com.djzhou.gmms.model.backlog.TbBacklog;
import com.djzhou.gmms.model.menu.TbMenu;
import com.djzhou.gmms.model.warning.TbWarning;

public class IndexAction extends BaseAction<TbMenu> {
	
	private static final long serialVersionUID = -5973326136288837316L;
	private List<TbMenu> parentMenuList;
	private List<TbMenu> childMenuList;
	private Integer parentMenuId;
	private TbMenu parentMenu;
	private String firstMenuUrl;
	private Integer announcementCount;
	private Integer messageCount;
	
	private List<TbBacklog> backlogList;
	private Integer backlogCount;
	private List<TbWarning> warningList;
	private Integer warningCount;
	private Integer emailCount;
	private TbMenu firstMenu;
	
	
	public String index(){
		parentMenuList=menuService.queryMenuListByParentId(0,queryCompany().getCompanyId(),queryDepartment().getDepartmentId(),queryRoleIds4Java());
		announcementCount=announcementService.queryAnnouncementCount();
		messageCount=messageService.queryMessageCount(queryUser().getUserId());
		//emailCount=emailService.queryReceiverCount(queryUser().getUserId());
//		backlogList=backlogService.queryList(queryUser().getUserId());
//		backlogCount=backlogList.size();
//		warningList=warningService.queryList(queryUser().getUserId());
//		warningCount=warningList.size();
		return SUCCESS;
	}
	
	public String leftMenu(){
		if(parentMenuId!=null){
			childMenuList=menuService.queryMenuListByParentId(parentMenuId,queryCompany().getCompanyId(),queryDepartment().getDepartmentId(),queryRoleIds4Java());
			parentMenu=menuService.queryById(parentMenuId);
			setParentMenuId(parentMenuId);
			if(currentMenuId!=0){
				TbMenu menu=menuService.queryById(currentMenuId);
				firstMenuUrl=menu.getMenuUrl()+"?currentMenuId="+menu.getMenuId();
				firstMenu=menu;
			}else{
				if(childMenuList!=null && childMenuList.size()!=0){
					firstMenuUrl=childMenuList.get(0).getMenuUrl()+"?currentMenuId="+childMenuList.get(0).getMenuId();
					firstMenu=childMenuList.get(0);
				}else{
					firstMenu=new TbMenu();
					firstMenu.setMenuUrl("/welcome.jsp");
					firstMenu.setMenuId(0);
				}
			}
			
			
		}
		return SUCCESS;
	}
	
	public String jumpPage(){
		return SUCCESS;
	}

	public List<TbMenu> getParentMenuList() {
		return parentMenuList;
	}

	public void setParentMenuList(List<TbMenu> parentMenuList) {
		this.parentMenuList = parentMenuList;
	}

	public List<TbMenu> getChildMenuList() {
		return childMenuList;
	}

	public void setChildMenuList(List<TbMenu> childMenuList) {
		this.childMenuList = childMenuList;
	}

	public Integer getParentMenuId() {
		return parentMenuId;
	}

	public void setParentMenuId(Integer parentMenuId) {
		this.parentMenuId = parentMenuId;
	}

	public TbMenu getParentMenu() {
		return parentMenu;
	}

	public void setParentMenu(TbMenu parentMenu) {
		this.parentMenu = parentMenu;
	}

	public String getFirstMenuUrl() {
		return firstMenuUrl;
	}

	public void setFirstMenuUrl(String firstMenuUrl) {
		this.firstMenuUrl = firstMenuUrl;
	}

	public Integer getAnnouncementCount() {
		return announcementCount;
	}

	public void setAnnouncementCount(Integer announcementCount) {
		this.announcementCount = announcementCount;
	}

	public Integer getMessageCount() {
		return messageCount;
	}

	public void setMessageCount(Integer messageCount) {
		this.messageCount = messageCount;
	}

	public List<TbBacklog> getBacklogList() {
		return backlogList;
	}

	public void setBacklogList(List<TbBacklog> backlogList) {
		this.backlogList = backlogList;
	}

	public Integer getBacklogCount() {
		return backlogCount;
	}

	public void setBacklogCount(Integer backlogCount) {
		this.backlogCount = backlogCount;
	}

	public List<TbWarning> getWarningList() {
		return warningList;
	}

	public void setWarningList(List<TbWarning> warningList) {
		this.warningList = warningList;
	}

	public Integer getWarningCount() {
		return warningCount;
	}

	public void setWarningCount(Integer warningCount) {
		this.warningCount = warningCount;
	}

	public Integer getEmailCount() {
		return emailCount;
	}

	public void setEmailCount(Integer emailCount) {
		this.emailCount = emailCount;
	}

	public TbMenu getFirstMenu() {
		return firstMenu;
	}

	public void setFirstMenu(TbMenu firstMenu) {
		this.firstMenu = firstMenu;
	}
	
	
	
}
